package main

import (
	"io"
	"net"
	"time"
)

// 核心接口定义 - 只保留必要的接口

// Request 请求接口
type Request interface {
	GetID() string
	GetData() []byte
}

// Response 响应接口
type Response interface {
	GetID() string
	GetData() []byte
	IsComplete() bool
}

// ProtocolConverter 协议转换器接口
type ProtocolConverter interface {
	ConvertRequest(tcpData []byte) (Request, error)
	ConvertResponse(response Response) ([]byte, error)
	GetProtocolName() string
}

// TunnelHandler 隧道处理器接口
type TunnelHandler interface {
	HandleConnection(tunnelConn net.Conn, tunnelID string) error
}

// TargetConnector 目标连接器接口
type TargetConnector interface {
	SendRequest(conn net.Conn, request Request) (Response, error)
}

// ConnectionManager 连接管理器接口
type ConnectionManager interface {
	CreateConnection(address string) (net.Conn, error)
}

// PacketSender 数据包发送器接口
type PacketSender interface {
	SendPacket(conn net.Conn, data []byte) error
}

// ErrorHandler 错误处理器接口
type ErrorHandler interface {
	HandleError(err error, context string) error
	ShouldRetry(err error) bool
	GetRetryDelay(attemptCount int) time.Duration
}

// StreamForwarder 流式转发器接口
type StreamForwarder interface {
	StreamForward(src io.Reader, dst io.Writer, requestID string) (int64, error)
}
